#pragma once

#include "afxstd.h"
#include <osg/Geode>
#include <osg/Node>
#include <osg/Geometry>
#include <osgDB/Registry>
#include <osgDB/WriteFile>
#include <osg/Notify>
#include <osg/ref_ptr>
#include <osgViewer/Viewer>
#include <osgUtil/SceneView>
#include "wx/defs.h"
#include "wx/app.h"
#include "wx/cursor.h"
#include "wx/glcanvas.h"
#include "wxscenecanvasbase.h"
using namespace osg;
using namespace std;
class wxSceneView;
class wxSceneGraphicsContext;

class wxSceneCanvas :
    public wxSceneCanvasBase
{
public:
    wxSceneCanvas(osgViewer::CompositeViewer* viewer,
		wxWindow* parent=(wxWindow*)NULL,
        wxWindowID id=wxID_ANY,
        const wxPoint &pos=wxDefaultPosition,
        const wxSize &size=wxDefaultSize,
        const wxString &name=wxT("OSG"),
        long style=0,
        int *attributes=0
        );
  virtual ~wxSceneCanvas();
public:
    wxSceneView* GetView();
    void SetView(wxSceneView* view);
    void updateWhenIdle(bool update);
    void setUpdateWhenIdleOverride(bool status);
	bool isRenderingActive();
	void setRenderingActive(bool active);
private:
    void OnPaint(wxPaintEvent& event);
    void OnEraseBackground(wxEraseEvent& event);
    void OnIdle(wxIdleEvent& event);
    void OnSize(wxSizeEvent& event);
    void OnShow(wxShowEvent& event);
private:
    osg::ref_ptr<osgViewer::CompositeViewer> pCompositeViewer;
    osg::ref_ptr<wxSceneView> pSceneView;    
    osg::ref_ptr<wxSceneGraphicsContext> pGraphicContext;
    bool mIsRenderingActive;
    int mIsMouseCaptured;
    bool mUpdateOnIdle;
    bool mUpdateOnIdelOverride;
    
    DECLARE_EVENT_TABLE();
};

